/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: CanIfCfg.h
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: CanIf
*
*******************************************************************************/

#ifndef CANIFCFG_H
#define CANIFCFG_H

/** HEADER FILES **/
#include "CanIfType.h"
#include "CanIfRte.h" 
#include "CanDrvCfg.h" 


/** MACRO DEFINITION **/
#define CanIfConf_CanIfTxPduCfg_Pdu_Channel1_101 0u
#define CanIfConf_CanIfTxPduCfg_Pdu_Channel1_102 1u
#define CanIfConf_CanIfTxPduCfg_Pdu_Channel1_720 2u
#define CanIfConf_CanIfTxPduCfg_Pdu_Channel1_500 3u
#define CanIfConf_CanIfTxPduCfg_Pdu_Max 4u

#define CanIfConf_CanIfRxPduCfg_Pdu_Channel1_201 PduRConf_CanIfRxPdu_Other_Can1_201
#define CanIfConf_CanIfRxPduCfg_Pdu_Channel1_202 PduRConf_CanIfRxPdu_Other_Can2_202
#define CanIfConf_CanIfRxPduCfg_Pdu_Channel1_710 0u
#define CanIfConf_CanIfRxPduCfg_Pdu_Channel1_7DF 1u
#define CanIfConf_CanIfRxPduCfg_Pdu_Channel1_Nm 0u
#define CanIfConf_CanIfRxPduCfg_Pdu_Max 5u

#define CanIfConf_CtrlDrv_0 0u
#define CanIfConf_CtrlDrv_Max 1u

#define CANID_INVALID_VALUE 0xFFFFFFFF

/** TYPEDEF DEFINITION **/
typedef struct
{
    CanControllerType* CanIfCtrlCanCtrlRef;
    uint8 CanIfCtrlId;
    uint8 CanIfCtrlWakeupSupport;
}CanIfCtrlCfgType;

typedef struct
{
    CanIfCtrlCfgType CanIfCtrlCfg;
}CanIfCtrlDrvCfgType;


typedef struct
{
    CanIfCtrlCfgType* CanIfHthCanCtrlIdRef;
    CanHardwareObjectType* CanIfHthIdSymRef;
}CanIfHthCfgType;


typedef struct
{
    CanIfHthCfgType* CanIfBufferHthRef;
    uint8 CanIfBufferSize;
}CanIfBufferCfgType;


typedef uint8 CanIfTxPduUserTxConfirmationULType;
#define CANIF_TX_PDU_UL_CAN_TP ((CanIfTxPduUserTxConfirmationULType)0x01)
#define CANIF_TX_PDU_UL_PDUR ((CanIfTxPduUserTxConfirmationULType)0x02)
#define CANIF_TX_PDU_UL_CAN_NM ((CanIfTxPduUserTxConfirmationULType)0x03)
#define CANIF_TX_PDU_UL_J1939TP ((CanIfTxPduUserTxConfirmationULType)0x04)
#define CANIF_TX_PDU_UL_XCP ((CanIfTxPduUserTxConfirmationULType)0x05)
#define CANIF_TX_PDU_UL_CDD ((CanIfTxPduUserTxConfirmationULType)0x06)
#define CANIF_TX_PDU_UL_J1939NM ((CanIfTxPduUserTxConfirmationULType)0x07)
#define CANIF_TX_PDU_UL_CAN_TSYN ((CanIfTxPduUserTxConfirmationULType)0x08)
#define CANIF_TX_PDU_UL_MAX (8u)


typedef uint8 CanIfTxPduCanIdTypeType;
#define CANIF_TX_PDU_TYPE_STANDARD_CAN ((CanIfTxPduCanIdTypeType)0x01)
#define CANIF_TX_PDU_TYPE_EXTENDED_CAN ((CanIfTxPduCanIdTypeType)0x02)
#define CANIF_TX_PDU_TYPE_STANDARD_FD_CAN ((CanIfTxPduCanIdTypeType)0x03)
#define CANIF_TX_PDU_TYPE_EXTENDED_FD_CAN ((CanIfTxPduCanIdTypeType)0x04)

typedef struct
{
    CanIfTxPduCanIdTypeType CanIfTxPduCanIdType;
    uint32 CanIfTxPduId;
    uint32 CanIfTxPduCanId;
    CanIfTxPduUserTxConfirmationULType CanIfTxPduUserTxConfirmationUL;
    CanIfBufferCfgType* CanIfTxPduBufferRef;
    PduType* CanIfTxPduRef;
}CanIfTxPduCfgType;


typedef uint8 CanIfRxPduUserRxIndicationULType;
#define CANIF_RX_PDU_UL_CAN_TP ((CanIfRxPduUserRxIndicationULType)0x01)
#define CANIF_RX_PDU_UL_PDUR ((CanIfRxPduUserRxIndicationULType)0x02)
#define CANIF_RX_PDU_UL_CAN_NM ((CanIfRxPduUserRxIndicationULType)0x03)
#define CANIF_RX_PDU_UL_J1939TP ((CanIfRxPduUserRxIndicationULType)0x04)
#define CANIF_RX_PDU_UL_XCP ((CanIfRxPduUserRxIndicationULType)0x05)
#define CANIF_RX_PDU_UL_CDD ((CanIfRxPduUserRxIndicationULType)0x06)
#define CANIF_RX_PDU_UL_J1939NM ((CanIfRxPduUserRxIndicationULType)0x07)
#define CANIF_RX_PDU_UL_CAN_TSYN ((CanIfRxPduUserRxIndicationULType)0x08)
#define CANIF_RX_PDU_UL_MAX (9u)


typedef uint8 CanIfRxPduCanIdTypeType;
#define CANIF_RX_PDU_TYPE_STANDARD_CAN ((CanIfRxPduCanIdTypeType)0x01)
#define CANIF_RX_PDU_TYPE_EXTENDED_CAN ((CanIfRxPduCanIdTypeType)0x02)
#define CANIF_RX_PDU_TYPE_STANDARD_FD_CAN ((CanIfRxPduCanIdTypeType)0x03)
#define CANIF_RX_PDU_TYPE_EXTENDED_FD_CAN ((CanIfRxPduCanIdTypeType)0x04)

typedef struct
{
    uint32 CanIfHrhRangeRxPduLowerCanId;
    uint32 CanIfHrhRangeRxPduUpperCanId;  
}CanIfHrhRangeCfgType;


typedef struct
{
    CanIfCtrlCfgType* CanIfHrhCanCtrlIdRef;
    CanHardwareObjectType* CanIfHrhIdSymRef;
    uint8 CanIfHrhSoftwareFilter;
    CanIfHrhRangeCfgType CanIfHrhRangeCfg;
}CanIfHrhCfgType;

typedef struct
{
    CanIfHrhCfgType* CanIfRxPduHrhIdRef;
    uint32 CanIfRxPduId;
    uint32 CanIfRxPduCanId;
    uint16 CanIfRxPduDataLength;
    CanIfRxPduUserRxIndicationULType CanIfRxPduUserRxIndicationUL;
    PduType* CanIfRxPduRef;
}CanIfRxPduCfgType;

typedef enum
{
    CANIF_CAN_TYPE_STANDARD = 0x00, /* standard */
    CANIF_CAN_TYPE_EXTENDED            /* extended */
}CANIF_CAN_TYPE_E;

typedef struct
{
    uint32 u32_canId;
    uint8  u8_length;
    CANIF_CAN_TYPE_E e_canType;
}CANIF_PDU_CFG_S;

typedef struct
{
    uint32 canId;
    uint8  length;
} CanIf_TxPduCfgType;

typedef struct
{
    uint32 canId;
    uint8  length;
    PduIdType UpperPduId;
} CanIf_RxPduCfgType;
/** LOCAL DATA DEFINITION **/
extern const CanIfTxPduCfgType CanIfTxPduCfg[CanIfConf_CanIfTxPduCfg_Pdu_Max];
extern const CanIfRxPduCfgType CanIfRxPduCfg[CanIfConf_CanIfRxPduCfg_Pdu_Max];

extern const PduIndicationFuncType Canif_RxIndicationFuncCfg[CANIF_RX_PDU_UL_MAX];


#endif
